from rest_framework import serializers

from goods.models import SPUSpecification, SpecificationOption


class SpecsSerializer(serializers.ModelSerializer):
    # 商品规格序列化器类

    spu = serializers.StringRelatedField(label='SPU名称')
    spu_id = serializers.IntegerField(label='SPU ID')
    # spec_id = serializers.IntegerField(label='规格id')

    class Meta:
        model = SPUSpecification
        fields = ('id', 'name', 'spu', 'spu_id')

    # def create(self, validated_data):
    #
    #     id = validated_data['id']
    #
    #     specs = super().create(validated_data)
    #
    #    pass


# class SimpleSerializer(serializers.ModelSerializer):
#     # 商品规格简单展示序列化器类
#
#     spec_id = serializers.IntegerField(label='规格id')
#     spec = serializers.StringRelatedField(label='规格名称')
#     # name = serializers.CharField(label='规格名称')
#     class Meta:
#         model = SpecificationOption
#         fields = ('id', 'value','spec','spec_id')
# class SimpleSerializer(serializers.ModelSerializer):
#     # 商品规格序列化器类
#
#
#     class Meta:
#         model = SPUSpecification
#         fields = ('id', 'name')

#######################33333

